


Vue.createApp({
    // 定义组件
    components:{
    },
    // 初始化
    setup(){
        // reactive定义变量运行存储
        // toRefs将数据返回
        const {
            reactive, toRefs
        } = Vue
        // 定义变量，即所需数据
        const state = reactive({
            user: {},
            isFollow: false,
            href:[
                "/userArticle",
                "/likeArticle",
                "/commentArticle",
                "/followUser",
            ],
            menu:[
                {
                    name: "文章",
                },
                {
                    name: "喜欢",
                },
                {
                    name: "评论",
                },
                {
                    name: "关注",
                },
            ],
            html: null
        })
        // 获取数据
        let that = state
        let href = location.href.split("/")
        let userId = href[href.length - 1]
        $.get("/getUserById/" + userId, function(data){
            that.user = data
        })
        
        get("/isFollow/" + userId, function (isFollow) {
            that.isFollow = isFollow
        })
        // 初始化为推荐页
        get(that.href[0], null, function(data){
            replaceHtml("#dynamic #main", data.responseText)
        })
        switchClass("#dynamic #nav ul>li", "#dynamic #main", that.href)
        // 返回数据
        return {
            ...toRefs(state)
        }
    }
    // 绑定app
}).mount("#dynamic")